//
// Created by lzd on 2021/9/8.
//
//多项式求和从低阶到高阶
#include <iostream>
using namespace std;

template <class T>
T PolyEval(T coeff[], int n, const T& x) {
    T y = 1, value = coeff[0];
    for (int i = 1; i <= n; i++) {
        y *= x;
        value += y * coeff[i];
    }
    return value;
}

int main() {
    int a[] = {7, 1, -4, 5};
    cout << PolyEval(a, 3, 2);
    return 0;
}